<?php

namespace app;

// 应用请求对象类
class Request extends \think\Request
{
    /**
     * 获取server参数
     * @access public
     * @param  string $name 数据名称
     * @param  string $default 默认值
     * @return mixed
     */
    public function server(string $name = '', string $default = '')
    {
        if (empty($name)) {
            return $this->server;
        }
        $str = $this->server[strtoupper($name)] ?? $default;
        if ($str != "" && $name === "PATH_INFO") {
            $str = iconv('GBK', 'UTF-8', $this->server[strtoupper($name)]); //中文乱码修复
        }
        return $str;
    }
}
